import pickle

import re

from jiquanquan.sample import pfr_opt, match_algorithm

# text_data = [[1,2,3],[4,5,6]]
# text_txt = '../../docs/corpus/tempData/2014_dic.txt'
# with open(text_txt, 'wb') as text:
# 	pickle.dump(text_data, text)

# with open(text_txt, 'rb') as text:
#     dic = pickle.load(text)

# #  下面测试2014会显示进度条
# in_path = '../../docs/corpus/originalData/2014_pfr_corpus.txt'
# out_path = '../../docs/corpus/tempData/2014_processed_text.txt'
# dic_path = '../../docs/corpus/tempData/2014_dic.txt'
# test_text_path = '../../docs/corpus/tempData/2014_test_text.txt'
# fmm_res_path = '../../docs/corpus/resultData/2014_fmm_result.txt'

# print(pfr_opt.FourteenPfr(in_path, out_path).generate_dict(dic_path))
# 最大前向匹配
# match_algorithm.run_fmm(in_path, out_path, dic_path, test_text_path, fmm_res_path)

# 最大后向匹配
# bmm_res_path = '../../docs/corpus/resultData/2014_bmm_result.txt'
# match_algorithm.run_bmm(in_path, out_path, dic_path, test_text_path, bmm_res_path)

# 双向匹配
# bdt_mm_res_path = '../../docs/corpus/resultData/2014_bdt_mm_result.txt'
# match_algorithm.run_bdt_mm(fmm_res_path, bmm_res_path, bdt_mm_res_path)

# 隐马可夫模型


#  下面测试1998,会显示进度条
in_path = '../../docs/corpus/originalData/199801_PeopleDaily.txt'
out_path = '../../docs/corpus/tempData/199801_processed_text.txt'
dic_path = '../../docs/corpus/tempData/199801_dic.txt'
test_text_path = '../../docs/corpus/tempData/199801_test_text.txt'
fmm_res_path = '../../docs/corpus/resultData/199801_fmm_result.txt'
corpus_cat = '98'

# 最大前向匹配
# match_algorithm.run_fmm(in_path, out_path, dic_path, test_text_path, fmm_res_path, corpus_cat)

# 最大后向匹配
bmm_res_path = '../../docs/corpus/resultData/199801_bmm_result.txt'
# match_algorithm.run_bmm(in_path, out_path, dic_path, test_text_path, bmm_res_path, corpus_cat)

# 双向匹配
bdt_mm_res_path = '../../docs/corpus/resultData/199801_bdt_mm_result.txt'
# match_algorithm.run_bdt_mm(fmm_res_path, bmm_res_path, bdt_mm_res_path)

# 隐马可夫模型
hmm_res_path = '../../docs/corpus/resultData/199801_hmm_result.txt'
match_algorithm.run_hmm_model(out_path, test_text_path, hmm_res_path)
